package com.lfg.leetcode.leetcode100;


import com.lfg.leetcode.leetcode0.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class No145postorderTraversal {

    public static void main(String[] args) {
        List<Integer> ret = postorderTraversal(TreeNode.stringToTreeNode("[1,null,2,3]"));
        System.out.println(ret);
    }

    public static List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> ret = new ArrayList<>(100);
        postorderTraversal(root, ret);
        return ret;
    }

    public static void postorderTraversal(TreeNode root, List<Integer> ret) {
        if (null == root) {
            return;
        }
        postorderTraversal(root.left, ret);
        postorderTraversal(root.right, ret);
        ret.add(root.val);
    }
}
